//
//  SpecialModel.m
//  Shengzhuli
//
//  Created by FXGuo on 2018/2/11.
//  Copyright © 2018年 kamangkeji. All rights reserved.
//

#import "SpecialModel.h"
#import "NSDate+Extension.h"

@implementation SpecialModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if (self = [super init]) {
        self.ID = dict[@"id"];
        self.name = dict[@"name"];
        self.content = dict[@"content"];
        self.price = [dict[@"price"] floatValue];
        self.maxDay = [dict[@"maxDay"] integerValue];
        self.startDate = [NSDate spToDate:dict[@"startDate"]];
        self.maxReserve = [dict[@"maxReserve"] integerValue];
    }
    return self;
}

+ (instancetype)objectWithDict:(NSDictionary *)dict
{
    return [[SpecialModel alloc]initWithDict:dict];
}

- (NSMutableArray *)tickets
{
    if (!_tickets) {
        _tickets = [NSMutableArray array];
    }
    return _tickets;
}
//时间戳转时间
- (NSString *)spToDateString:(NSString *)sp
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    formatter.dateFormat = @"MM-dd";
    
    NSDate *timeDate = [NSDate dateWithTimeIntervalSince1970:[sp floatValue]/1000];
    return [formatter stringFromDate:timeDate];
}

@end
